package ru.mipt.simt;

import java.awt.Dimension;

import javax.swing.JFrame;

import ru.mipt.simt.ui.RoadPanel;

public class Runner
{
	public static void main(String[] args) throws InterruptedException
	{
		Road road = new Road();

		final JFrame frame = new JFrame("Симуляция");
		RoadPanel panel = new RoadPanel(road, 0, 1000);
		panel.setPreferredSize(new Dimension(700, 100));
		frame.add(panel);

		new Thread()
		{
			@Override
			public void run()
			{

				frame.pack();
				frame.setVisible(true);
			}
		}.start();

		double t = 0;
		double dt = 1e-4;
		int n = 0;
		while (t < 10000)
		{
			road.update(t);
			t += dt;
			n++;
			if (n >= 1000)
			{
				n = 0;
				System.out.println(t);
				frame.repaint();
			}

		}
	}
}
